@model TjingMe.Web.Models.Event
@{
    ViewBag.Title = "Create";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<script type="text/javascript">

function ajaxValidate() {
  return $('form').validate().form();
}

function getGbPostSuccess(ajaxContext){
  // .... it is not necessary to do anything here.
  window.location.href= ajaxContext;
}
function showFaliure(ajaxContext){
   alert('Det gick fel');
}
</script>
@using (Ajax.BeginForm("Create", "Event", new AjaxOptions
                        {
                            UpdateTargetId = "form1",
                            InsertionMode = InsertionMode.Replace,
                            OnBegin = "ajaxValidate",
                            OnSuccess = "getGbPostSuccess",
                            OnFailure = "showFaliure"
                        }))
{

<text>Skapa ditt egna tjing event:</text>
@Html.EditorFor(m=>m.Name)
<br/>
<text>Ditt event kommer ha följande kod:</text>
@Html.DisplayFor(m=>m.Key)
@Html.HiddenFor(m=>m.Key)
<br/>
<input type="submit" value="Skapa"/>

}